package org.wqp.redisson.main;

import org.redisson.api.RLock;
import org.wqp.redisson.utils.RedissonUtil;

public class MyTask implements Runnable {
    RLock lock = null;

    public MyTask( RLock lock) {
        this.lock = lock;
    }

    public void run() {
        System.out.println(Thread.currentThread().getName() + " begin.");

        lock.lock();
        System.out.println(Thread.currentThread().getName() + " get lock.");
        try {
            Thread.sleep(3000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        } finally {
            lock.unlock();
            System.out.println(Thread.currentThread().getName() + " release lock.");
        }
        System.out.println(Thread.currentThread().getName() + " end.");
    }
}